package java08;
class EmergencyThread implements Runnable{
    public void run(){
        for(int i = 1; i < 6; i++){
            System.out.println(Thread.currentThread().getName() + "输入：" + i);
        }
    }
}
public class RunnableTest04 {
    public static void main(String[] args){
        //创建线程
        Thread thread1 = new Thread(new EmergencyThread(),"thread1");
        thread1.start();//开启线程
        for(int i = 1; i < 6; i++){
            System.out.println(Thread.currentThread().getName() + "输入：" +i);
            if(i == 2){
                try {
                    thread1.join();//调用join()方法
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
